<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<include file="Public/common_header" />
<div class="mian">
<include file="Public/sidebar" menu="xtgl.gysgl"  />
   <div class="mianR">
      <div class="yuyue">
         <ul>
            <li onclick="get_list(1);" id="status1">4S店</li>
            <!-- <li onclick="get_list(2);" >经纪公司</li> -->
            <li onclick="get_list(3);" id="status3">集团</li>
            <?php if ($reginAuth): ?>
              <li onclick="get_list(4);" id="status4">片区</li>
            <?php endif ?>
         </ul>
         <input type="hidden" name="status" value="{$status}">
      </div>
      <div class="group">
          <div class="group-search" id="search1">
            <form id="searchFrom1">
              <select name="bc_list" id="bc_list">
                <?php if ($is_maintain): ?>
                  <option value="{$BranchEmp.branch_id}" selected='selected'>{$BranchEmp.name}</option>   
                <?php else: ?>
                  <option value="0">请选择分公司</option>   
                  <?php foreach ($bc_list as $k => $v): ?>
                      <option value="{$k}" >{$v}</option>
                  <?php endforeach ?>
                <?php endif ?> 
              </select>
              <select name="bc_city" id="bc_city">
                <?php if ($is_maintain): ?>
                  <option value="{$cityEmp.city_code}" selected='selected'>{$cityEmp.city_name}</option>   
                <?php else: ?>
                  <option value="0" selected='selected'>请选择城市</option>   
                <?php endif ?>
                
              </select>
              <select name="region_id" id="region_id">
                <?php if ($is_maintain): ?>
                  <option value="{$regionEmp.region_id}" selected='selected'>{$regionEmp.region_name}</option>   
                <?php else: ?>
                  <option value="0" selected='selected'>请选择片区</option>   
                <?php endif ?>
              </select>
              <select name="maintain_id" id="maintain_id">
                <?php if ($is_maintain && $is_leader): ?>
                  <option value="0" selected='selected'>请选择维护人</option>
                  <?php foreach ($resMaintain as $k66 => $v66): ?>
                     <option value="{$v66.emp_id}" >{$v66.real_name}</option>
                   <?php endforeach ?> 
                <?php elseif($is_maintain && !$is_leader): ?>
                  <option value="{$user_info.emp_id}" selected='selected'>{$user_info.real_name}</option>
                <?php else: ?>
                  <option value="0" selected='selected'>请选择维护人</option>   
                <?php endif ?>
              </select>
              <input type="text" class="group-text" value="{$params.fid}" name="fid" placeholder="店铺ID"  />
              <input type="text" class="group-text" value="{$params.f_name}" name="f_name" placeholder="店铺名称" />
              <input type="text" class="group-text" value="{$params.developer_phone}" name="developer_phone" placeholder="开发人电话" />
              <input type="text" class="group-text" value="{$params.maintain_phone}" name="maintain_phone" placeholder="维护人电话" />
              <input type="button" value="搜索" class="search-btn" onclick="search()" />
              <?php if ($foursAddAuth): ?>
                <a class="addto" href="/SupplierManage/addFourStore">添加4S店</a>
              <?php endif ?>
              </form>
          </div>
          <div class="group-search" id="search3" style="display:none">
            <form id="searchFrom3">
              <select name="branch_id">
                <?php if ($is_hq): ?>
                 <option value="0">请选择分公司</option>   
                <?php endif ?>
                <?php foreach ($bc_list as $k => $v): ?>
                    <option value="{$k}" >{$v}</option>
                <?php endforeach ?>
              </select>
              <input type="text" class="group-text" value="{$params.b_name}" name="b_name" placeholder="集团名称" />
              <input type="text" class="group-text" value="{$params.b_contact}" name="b_contact" placeholder="联系人" />
              <input type="text" class="group-text" value="{$params.b_phone}" name="b_phone" placeholder="联系电话" />
              <input type="button" value="搜索" class="search-btn" onclick="search()" />
              <?php if ($blocAddAuth): ?>
                <a class="addto" href="/SupplierManage/addBloc">添加集团</a>
              <?php endif ?>
            </form>
          </div>
          <div class="group-search" id="search4" style="display:none">
            <form id="searchFrom4">
              <select name="bc_list" id="region_bc_list">
                 <option value="0">请选择分公司</option>   

                <?php foreach ($bc_list as $k => $v): ?>
                    <option value="{$k}" >{$v}</option>
                <?php endforeach ?>
              </select>
              <select name="bc_city" id="region_bc_city">
                <option value='0' >请选择城市</option>
              </select>
              <input type="text" class="group-text" value="{$params.region_name}" name="region_name" placeholder="片区名称" />
              <input type="text" class="group-text" value="{$params.leader_contact}" name="leader_contact" placeholder="负责人" />
              <input type="text" class="group-text" value="{$params.leader_phone}" name="leader_phone" placeholder="负责人电话" />
              <input type="button" value="搜索" class="search-btn" onclick="search()" />
              <?php if ($reginAddAuth): ?>
                <a class="addto" href="/SupplierManage/addRegion" >添加片区</a>
              <?php endif ?>
            </form>
          </div>
      </div>

      <div class="listBox" id="listBox">
         
      </div>
      <div class="clear"></div>
   </div>

</div>
<script type="text/javascript">
  // $(function(){
  //   $(".yuyue ul li").on("click",function(){
  //     var index=$(".yuyue ul li").index(this);
  //     $(".group .group-search").eq(index).show().siblings().hide();
  //   })
  // })
   get_list({$status});
   $("#search"+{$status}).show().siblings().hide();
   $("#status"+{$status}).addClass('yuCurrent').siblings().removeClass('yuCurrent');
   function get_list(status){
       $('input[name=status]').val(status);
       $("#search"+status).show().siblings().hide();
       $.get("/SupplierManage/get_list",$("#searchFrom"+status).serialize()+"&status="+status,function(data){
           $("#listBox").html(data);
           $("input").placeholder();
       },"html");
   }

   function get_page(p){
       var status = $('input[name=status]').val();
       $.get("/SupplierManage/get_list", $("#searchFrom"+status).serialize()+"&p="+p+"&status="+status, function(data){
           $("#listBox").html(data);
           $("input").placeholder();
       },"html");
   }
    function search(){
        var status = $('input[name=status]').val();
        $.get("/SupplierManage/get_list",$("#searchFrom"+status).serialize()+"&status="+status,function(data){
            $("#listBox").html(data);
            $("input").placeholder();
        },"html");
    }
  
$("#region_bc_list").change(function () {
    var branch_id = $(this).val();
    $.post("/SupplierManage/getCityByBranchId", {"branch_id": branch_id}, function (data) {
        var optstr = '';
        if (data.code == 200) {
            $.each(data.data, function (k, val) {
                optstr += "<option value='" + val.city_code + "'>" + val.city_name + "</option>"
            });
        }
        optstr = "<option value='0' selected='selected'>请选择城市</option>" + optstr;
        $("#region_bc_city").html(optstr);
    }, "json");
});

$("#bc_list").change(function () {
    var branch_id = $(this).val();
    $.post("/SupplierManage/getCityByBranchId", {"branch_id": branch_id}, function (data) {
        var optstr = '';
        if (data.code == 200) {
            $.each(data.data, function (k, val) {
                optstr += "<option value='" + val.city_code + "'>" + val.city_name + "</option>"
            });
        }
        optstr = "<option value='0' selected='selected'>请选择城市</option>" + optstr;
        $("#bc_city").html(optstr);
    }, "json");
});

$("#bc_city").change(function () {
    var city = $(this).val();
    $.post("/SupplierManage/getRegionByCity", {"city": city}, function (data) {
        var optstr = '';
        if (data.code == 200) {
            $.each(data.data, function (k, val) {
                optstr += "<option value='" + val.rid + "'>" + val.region_name + "</option>"
            });
        }
        optstr = "<option value='0' selected='selected'>请选择片区</option>" + optstr;
        $("#region_id").html(optstr);
    }, "json");
});

$("#region_id").change(function () {
    var region_id = $(this).val();
    $.post("/SupplierManage/getMaintainByRegionId", {"region_id": region_id}, function (data) {
        var optstr = '';
        if (data.code == 200) {
            $.each(data.data, function (k, val) {
                optstr += "<option value='" + val.emp_id + "'>" + val.real_name + "</option>"
            });
        }
        optstr = "<option value='0' selected='selected'>请选择维护人</option>" + optstr;
        $("#maintain_id").html(optstr);
    }, "json");
});

</script>
<include file="Public/foot" />